<jsp:useBean id="logUser" scope="session" type="com.personal.pojo.TMember"/>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑信息-会员</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>
<body>
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" action="" method="">
                <input type="text" hidden id="memid" value="${logUser.memid}">
                <div class="layui-form-item">
                    <label for="L_phone" class="layui-form-label">
                        登录账号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_phone" required lay-verify="phone"
                               autocomplete="off" value="${logUser.memlogname}" class="layui-input" readonly>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        登录凭证，无法修改，如需修改请联系管理员。
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" required="" lay-verify="pass"
                               autocomplete="off" class="layui-input" value="${logUser.mempassword}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        6到16个字符
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        真实名字
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_username" required lay-verify="required"
                               autocomplete="off" value="${logUser.memrealname}" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <c:if test="${logUser.memsex=='男'}">
                                <input type="radio" name="memsex" value="男" title="男" checked>
                                <input type="radio" name="memsex" value="女" title="女">
                            </c:if>
                            <c:if test="${logUser.memsex=='女'}">
                                <input type="radio" name="memsex" value="男" title="男">
                                <input type="radio" name="memsex" value="女" title="女" checked>
                            </c:if>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                    </label>
                    <button type="button" class="layui-btn" key="set-mine" lay-filter="save" id="save">
                        修改
                    </button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<script>
    $("#save").click(function (){
        layer.confirm('确定修改吗？',function (){
            $.ajax({
                url:"${pageContext.request.contextPath}/member/memedit.action",
                type:"post",
                data: {
                    memid:$("#memid").val(),
                    memlogname:$("#L_phone").val(),
                    mempassword:$("#L_pass").val(),
                    memrealname:$("#L_username").val(),
                    memsex:$("input[name='memsex']:checked").val()
                },
                dataType:"text",
                success:function (re){
                    console.log(re);
                    if ("ok"==re){
                        layer.msg("修改成功！",{icon:1});
                        //刷新页面，重置session内容
                        <%--window.top.location.href="${pageContext.request.contextPath}/member/toOneselfpage.action";--%>
                    }else{
                        alert("修改失败！");
                    }
                },
                error:function (re){
                    console.log("error"+re);
                }
            });
        });
    });
</script>
</body>
</html>
